package Subway;
/*
 * @Author（王思翰）

 * @Description（类的描述）**
 * @                           _ooOoo_
 *                            o8888888o
 *                            88" . "88
 *                            (| -_- |)
 *                            O\  =  /O
 *                         ____/`---'\____
 *                       .'  \\|     |//  `.
 *                      /  \\|||  :  |||//  \
 *                     /  _||||| -:- |||||-  \
 *                     |   | \\\  -  /// |   |
 *                     | \_|  ''\---/''  |   |
 *                     \  .-\__  `-`  ___/-. /
 *                   ___`. .'  /--.--\  `. . __
 *                ."" '<  `.___\_<|>_/___.'  >'"".
 *               | | :  `- \`.;`\ _ /`;.`/ - ` : | |
 *               \  \ `-.   \_ __\ /__ _/   .-` /  /
 *          ======`-.____`-.___\_____/___.-`____.-'======
 *                             `=---='
 *          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 *                     佛祖保佑        永无BUG

 * @Date（创建时间）11-13
 */
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Subway {

    public static void main(String[] args) {
        Station station = new Station();

        station.add();

        Map<Integer, String> stationMap = station.out();

        Set<Integer> setout = stationMap.keySet();

        for (Integer integer : setout) {

            System.out.println(integer + "--" + stationMap.get(integer));

        }

        String staticname=null;

        String endname=null;

        Scanner scanner = new Scanner(System.in);

        for (int i = 0; i < 11; i++) {

            System.out.println("请输入要上车的站：");

            staticname = scanner.nextLine();

            if (stationMap.containsValue(staticname)) {

                break;
            } else {

                System.out.println("你输入的站点不存在，请重新输入");

            }

        }


        for (int i = 0; i < 11; i++) {

            System.out.println("请输入你要去的站：");

            endname=scanner.nextLine();

            if (stationMap.containsValue(endname)){

                break;
            }else {

                System.out.println("你输入的站点不存在，请重新输入");
            }
        }

        int PlatformOne=0;

        int  PlatformTwo=0;

        int distance=0;

        int money=0;

        int time=0;

        Set<Integer> distanceset=stationMap.keySet();

        for (Integer integer : distanceset) {

            if (staticname.equals(stationMap.get(integer))){

                PlatformOne=integer;

            }
            if (endname.equals(stationMap.get(integer))){

                PlatformTwo=integer;
            }
        }
        if (PlatformOne>PlatformTwo){

            distance=PlatformOne-PlatformTwo;
        }else{

            distance=PlatformTwo-PlatformOne;
        }

        time=distance*2;

        if (distance<=3){

            money=3;
        }else if (distance<=5){

            money=4;
        }else {

            money=4+(distance-5)*2;
        }

        if (money==10){

            money=10;
        }else {

            money=money;
        }

        System.out.println("从"+staticname+"到"+endname+"共经过了"+distance+"站，并需要支付"+money+"，此路程总共需要大约"+time+"分钟");
    }

}
